{	Problem: http://codeforces.ru/problemset/problem/46/C
	Verdict: Accepted
}
var s:string; n,k,m,j,r,i:longint;
begin
readln(n);
readln(s);
m:=0;
for i:=1 to n do
    if s[i]='H' then inc(m);
s:=s+s;
r:=maxlongint;
for i:=1 to n do begin
    k:=0;
    for j:=i to i+m-1 do
        if s[j]='T' then inc(k);
    if k<r then r:=k;
end;
write(r);
end.
